package com.airlines.system.service.impl;

import com.airlines.system.dao.SysTypeMapper;
import com.airlines.system.domain.SysType;
import com.airlines.system.service.SysTypeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysTypeServiceImpl implements SysTypeService {

    @Autowired
    private SysTypeMapper sysTypeMapper;

   /* @Autowired
    private SysMenuMapper sysMenuMapper;
    @Autowired
    private SysRoleTypeMapper sysRoleTypeMapper;
*/

    @Override
    public List<SysType> findAll() {
        return sysTypeMapper.findAll();
    }

    @Override
    public SysType findById(String typeId) {
        return sysTypeMapper.selectByPrimaryKey(typeId);
    }

    /*@Override
    public Boolean addSysType(SysType sysType) {
        sysType.setId(UUID.randomUUID().toString());
        //有效
        sysType.setStatus(1);
        return sysTypeMapper.insertSelective(sysType) > 0 ? true : false;
    }

    @Override
    public Boolean editSysType(String id, SysType sysType) {
        return sysTypeMapper.updateByPrimaryKey(sysType) > 0 ? true : false;
    }

    @Override
    public List<SysMenu> findAllTypeMenu(String roleId) {

        List<SysMenu> resultList = new ArrayList<>();
        SysRoleTypeExample example = new SysRoleTypeExample();
        example.createCriteria().andRoleIdEqualTo(roleId);
        List<SysRoleType> roleTypes = sysRoleTypeMapper.selectByExample(example);
        if (roleTypes == null && roleTypes.size() > 0) {
            return resultList;
        }
        return sysMenuMapper.findMenusByTypeId(roleTypes.get(0).getTypeId());
    }*/
}
